package com.hehao.java_basic.stream;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Damon
 * @date 2022/2/24
 * 流也可以进行合并、去重、限制、跳过等操作
 * concat limit skip
 */
public class PickCombineDemo {
    public static void main(String[] args) {
        String[] arr1 = { "a", "b", "c", "d" };
        String[] arr2 = { "d", "e", "f", "g" };

        Stream<String> stream1 = Stream.of(arr1);
        Stream<String> stream2 = Stream.of(arr2);

        System.out.println(Stream.concat(stream1, stream2).distinct().collect(Collectors.toList()));

        System.out.println(Stream.iterate(1, x -> x + 2).limit(10).collect(Collectors.toList()));

        System.out.println(Stream.iterate(1, x -> x + 2).skip(1).limit(5).collect(Collectors.toList()));


    }
}
